﻿using System;
using System.Linq;
using StartWebForms.Data;

namespace StartWebForms.Person.IndividualPerson
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int personID = 0;

            if (!string.IsNullOrEmpty(Request["id"]))
            {
                int.TryParse(Request["id"], out personID);
                LoadPerson(personID);
            }
        }


        private void LoadPerson(int personID)
        {
            PersonsDataContext dataContext = new PersonsDataContext();

            Data.Person person = dataContext.Persons.Where
                (p => p.ID == personID).Single();

            this.ltrTitle.Text = person.Name;
            this.ltrName.Text = person.Name;
            this.ltrPersonName.Text = person.Name;
            this.ltrDateAdded.Text = person.DateAdded.ToString();
        }
    }
}
